<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        权限规则
    </title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link href="css/main.css" media="all" rel="stylesheet">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>会员管理</cite></a>
              <a><cite>权限规则</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);"
       style="line-height:1.6em;margin-top:3px;float:right" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()">
            <i class="layui-icon">&#xe640;</i>批量删除
        </button>
        <button class="layui-btn" onclick="rule_add('添加权限','auth_ruleadd.html','600','500')"><i class="layui-icon">&#xe608;</i>添加
        </button>
        <span class="x-right" style="line-height:40px">共有数据：<span class="layui-badge">0</span> 条</span>
    </xblock>

    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <input name="" type="checkbox" value="">
            </th>
            <th>
                ID
            </th>
            <th>
                权限规则
            </th>
            <th>
                权限名称
            </th>
            <th>
                等级
            </th>
            <th>
                时间
            </th>
            <th>
                状态
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody id="x-link">
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                1
            </td>
            <td>
                System/lst
            </td>
            <td>
                系统设置
            </td>
            <td>
                1级
            </td>
            <td>
                2019-08-30 21:32:53
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'1',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','1','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'1')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                2
            </td>
            <td>
                |——— System/lst
            </td>
            <td>
                |———基础设置
            </td>
            <td>
                2级
            </td>
            <td>
                2019-08-30 21:35:13
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'2',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','2','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'2')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                3
            </td>
            <td>
                |—————— System/edit
            </td>
            <td>
                |——————基础设置操作
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:43:04
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'3',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','3','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'3')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                9
            </td>
            <td>
                |——— Link/lst
            </td>
            <td>
                |———友情链接
            </td>
            <td>
                2级
            </td>
            <td>
                2019-08-30 21:54:24
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'9',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','9','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'9')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                10
            </td>
            <td>
                |—————— Link/lst
            </td>
            <td>
                |——————友情链接列表
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:54:52
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'10',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','10','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'10')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                11
            </td>
            <td>
                |—————— Link/add
            </td>
            <td>
                |——————友情链接添加修改
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:55:38
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'11',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','11','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'11')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                12
            </td>
            <td>
                |—————— Link/link_del
            </td>
            <td>
                |——————友情链接删除
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:56:17
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'12',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','12','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'12')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                13
            </td>
            <td>
                |—————— Link/start
            </td>
            <td>
                |——————友情链接审核
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:56:46
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'13',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','13','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'13')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                14
            </td>
            <td>
                |—————— Link/state
            </td>
            <td>
                |——————友情链接状态操作
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:57:20
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'14',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','14','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'14')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                4
            </td>
            <td>
                Admin/lst
            </td>
            <td>
                管理员管理
            </td>
            <td>
                1级
            </td>
            <td>
                2019-08-30 21:44:11
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'4',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','4','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'4')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                5
            </td>
            <td>
                |——— Admin/lst
            </td>
            <td>
                |———管理员列表
            </td>
            <td>
                2级
            </td>
            <td>
                2019-08-30 21:44:33
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'5',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','5','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'5')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                6
            </td>
            <td>
                |—————— Admin/add
            </td>
            <td>
                |——————管理员添加修改
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:45:44
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'6',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','6','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'6')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                7
            </td>
            <td>
                |—————— Admin/del
            </td>
            <td>
                |——————管理员删除
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:51:23
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'7',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','7','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'7')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                8
            </td>
            <td>
                |—————— Admin/admin_stop
            </td>
            <td>
                |——————管理员状态操作
            </td>
            <td>
                3级
            </td>
            <td>
                2019-08-30 21:52:35
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="rule_status(this,'8',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="rule_edit('编辑','auth_ruleadd.html','8','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="rule_del(this,'8')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>

    <div id="page"></div>
</div>
<script charset="utf-8" src="lib/layui/layui.js"></script>
<script charset="utf-8" src="js/x-layui.js"></script>
<script>
    layui.use(['element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        form = layui.form();//弹出层

        //监听提交
        form.on('submit(*)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6});
            $('#x-link').prepend('<tr><td><input type="checkbox"value="1"name=""></td><td>1</td><td>' + data.field.rules + '</td><td>' + data.field.name + '</td><td>' + data.field.cname + '</td><td class="td-manage"><a title="编辑"href="javascript:;"onclick="rule_edit(\'编辑\',\'link-edit.html\',\'4\',\'\',\'510\')"class="ml-5"style="text-decoration:none"><i class="layui-icon">&#xe642;</i></a> <a title="删除"href="javascript:;"onclick="rule_del(this,\'1\')"style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a></td></tr>');
            return false;
        });
    })

    //以上模块根据需要引入

    //批量删除提交
    function delAll() {
        layer.confirm('确认要删除吗？', function (index) {
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }

    /*添加*/
    function rule_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }

    /**
     * 权限状态
     **/
    function rule_status(obj, id, e) {
        layer.confirm(e == 1 ? '你确定要启用吗？' : '你确定要禁用吗？', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                type: "post",
                url: "xxx",
                data: {id: id, status: e},
                dataType: "json",
                success: function (data) {
                    if (data.status == 1) {
                        //发异步把用户状态进行更改
                        $(obj).attr("class", "layui-btn layui-btn-danger ");
                        $(obj).text("隐藏");
                        $(obj).remove();
                        layer.msg(data.info, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                        return false;
                    } else {
                        //发异步把用户状态进行更改
                        $(obj).attr("class", "layui-btn layui-btn-normal ");
                        $(obj).text("显示");
                        $(obj).remove();
                        layer.msg(data.info, {icon: 5, time: 1000});
                        return false;
                    }
                }
            });

        });
    }

    //-编辑
    function rule_edit(title, url, id, w, h) {
        url = url + "?id=" + id;
        x_admin_show(title, url, w, h);
    }

    /*删除*/
    function rule_del(obj, id) {
        layer.confirm('确认要删除吗？', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                type: "post",
                url: "xxxx",
                data: {id: id},
                dataType: "json",
                async: true,
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.info, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(data.info, {icon: 5, time: 1000});
                        return false;
                    }
                }
            });
        });
    }
</script>

</body>
</html>